package com.chenfan.process.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chenfan.process.common.utils.QueryWrapperUtils;
import com.chenfan.process.entity.po.ApprovalTemplateSnapshotPo;
import com.chenfan.process.repository.ApprovalTemplateSnapshotRepository;
import com.chenfan.process.service.ApprovalTemplateSnapshotService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author K
 * @date 2021/3/17
 */
@Service
public class ApprovalTemplateSnapshotServiceImpl
    extends ServiceImpl<ApprovalTemplateSnapshotRepository, ApprovalTemplateSnapshotPo>
    implements ApprovalTemplateSnapshotService {

    @Override
    public List<ApprovalTemplateSnapshotPo> listWithTemplateId(List<Long> approvalTemplateIdList) {
        QueryWrapper<ApprovalTemplateSnapshotPo> queryWrapper = QueryWrapperUtils.newQueryWrapper();
        queryWrapper.in(ApprovalTemplateSnapshotPo.APPROVAL_TEMPLATE_ID, approvalTemplateIdList);
        return list(queryWrapper);
    }

    @Override
    public List<ApprovalTemplateSnapshotPo> listTemplate(List<Long> approvalTemplateIdList) {
        QueryWrapper<ApprovalTemplateSnapshotPo> queryWrapper = QueryWrapperUtils.newQueryWrapper();
        queryWrapper.in(!CollectionUtils.isEmpty(approvalTemplateIdList), ApprovalTemplateSnapshotPo.APPROVAL_TEMPLATE_ID, approvalTemplateIdList);
        return list(queryWrapper);
    }
}
